<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sunstorm - Tin tức Online</title>
<link rel="shortcut icon" href="../Images/Icons/SunstormLogo.gif" />
<link rel="stylesheet" href="../CSS/css_webnews.css"/>
<link href="../Menu_Zing/SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />


<link href="../weather/weather.css" rel="stylesheet" type="text/css" />
<link href="../CSS/jquery.ui.stars.css" rel="stylesheet" type="text/css" />
<link href="../CSS/experiment.css" rel="stylesheet" type="text/css" />

<script src="../Menu_Zing/SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/jquery-ui-1.8.20.custom.min.js"></script> 
<script type="text/javascript" src="../Scripts/jquery.ui.stars.js"></script>
<!--<script type="text/javascript" src="../Scripts/jquery-ui.min.js" ></script> -->
<script language="javascript" src="../weather/js/ajax.js"></script>
<script language="javascript" src="../Scripts/floater_xlib.js"></script>
<script language="javascript" src="../Scripts/Advertise_twoside.js"></script>
<script language="javascript" src="../Scripts/jquery.textareaCounter.plugin.js"></script>
<script language="javascript" src="../Scripts/jquery.jqDock.min.js"></script>
<!--<script language="javascript" src="../Scripts/jquery.lightswitch.js"></script>-->
<style>
.commentbox
{
	background: -webkit-gradient(linear, left top, left bottom, from(#F9F9F9), to(#E9E9E9));
	box-shadow: 0 1px 1px white inset, 0 1px 2px rgba(0, 0, 0, 0.1) !important;
	padding: 10px 10px 5px;
	margin-bottom: 10px;
	border:solid 1px #eee;
}
.comment
{
	box-shadow: 0 1px 1px white inset, 0 1px 2px rgba(0, 0, 0, 0.1) !important;
	padding: 10px 10px 5px;
	margin-bottom: 10px;
	border:solid 1px #eee;
	background-color:#FFF;

}
.originalTextareaInfo 
{
	font-size: 12px;
	color: #000000;
	font-family: Tahoma, sans-serif;
	text-align: right
}
			
.warningTextareaInfo 
{
	font-size: 12px;
	color: #FF0000;
	font-family: Tahoma, sans-serif;
	text-align: right
}

</style>
</head>

<body>
<div id="main">
  <div class="header"></div>
  <div class="menu">
  <?php 
   $urlAds="../Images/Advertisement/";
  $urlNews="../Images/Img_News/";
  $urlIcon="../Images/Icons/";
  include("../Connections/connect_client.php");
  require_once("include/Advertise_twoside.php");
  require("../Menu_Zing/Zing/MenuNgang.php"); 
 require("include/JdockMenu.php");
 require("include/Feedback_modal.php");
  ?></div>
   <!----------------------------------------Bar Search + BreadCrumb------------------------------------------------------>
  <div class="searchBar" >
   <form action="SearchNews.php" method="get" id="frmQuicksearch">
    <div class="searchBox" >
        	<input type="text" placeholder="Tìm kiếm..." name="keyword"  />
            <input type="image" src="../Images/Icons/Knob Search.ico" onclick="form.frmQuicksearch.submit();"   />       
    </div>
  	</form>
  </div>
  <!----------------------------------------Content------------------------------------------------------>
  <div class="left">
    <div id="newsdetail">
    <?php
	$newsid=intval($_GET["id"]);
	 $query="UPDATE news SET Views = Views+1 WHERE NewsID=$newsid";
	 mysql_query($query);
	$query="SELECT n.NewsID, n.TopicID, n.Title, n.Description, n.Rating, n.MarkerNum,n.Source,n.CreatedDate,n.Content FROM news n WHERE n.NewsID=$newsid";
	$result=mysql_query($query);
	$news=mysql_fetch_assoc($result);
	
	?>
   	  <label class="createddate">Ngày đăng: <?php $sqldate=strtotime($news["CreatedDate"]); $date=date('d/m/Y',$sqldate); echo $date; ?></label><br />
        <h1><?php echo $news['Title']; ?></h1>
      <p class="titlenews">
        	<?php echo $news["Description"]; ?>
        </p>
    	<p class="contentnews">
        	<?php echo $news["Content"]; ?>
        </p>
        
         <p>
         <!------------------------------------Rating-------------------------------------->
      	<form>
            Đánh giá: <span id="stars-cap"></span>
            <div id="stars-wrapper1">
              <input type="radio" name="newrate" value="1" title="1 Điểm" />
              <input type="radio" name="newrate" value="2" title="2 Điểm" />
              <input type="radio" name="newrate" value="3" title="3 Điểm" />
              <input type="radio" name="newrate" value="4" title="4 Điểm" />
              <input type="radio" name="newrate" value="5" title="5 Điểm" />
              <input type="radio" name="newrate" value="6" title="6 Điểm" />
              <input type="radio" name="newrate" value="7" title="7 Điểm" />
              <input type="radio" name="newrate" value="8" title="8 Điểm" />
              <input type="radio" name="newrate" value="9" title="9 Điểm" />
              <input type="radio" name="newrate" value="10" title="10 Điểm" />
            </div><br />
            <div>Số lượt đánh giá: <i id="rating"><?php echo $news["MarkerNum"];?></i> Lượt</div>
        </form>
      <script type="text/javascript">
		$(document).ready(function(){
						   $("#stars-wrapper1").stars({
								captionEl: $("#stars-cap"),
								cancelShow:false,
								oneVoteOnly:true,
								callback: function(ui, type, value, event)
							
									{
									$.ajax({
											url:"include/Rating_submit.php",
											data:{id:<?php echo $newsid; ?>,rate:value},
											type:"post",
											dataType:"json",
											success:function(res)
												{
													if(res.ok)
													{
													$("#rating").html(res.total);
													}
																			 
												}
											});
							
									}
							}).stars("selectID",<?php $r=round(floatval($news["Rating"]),0); echo $r-1; ?>);
						   });
		</script>
      </p>
      <!------------------------------------------Comment------------------------------------- -->
      <p>
       <div class="commentbox">
       		<h3>Bình luận</h3>
            <div>
            <table width="100%" border="0" cellspacing="2" cellpadding="0">
              <tr>
                <td>Họ tên:</td>
                <td><input name="" type="text" id="txtCName" style="width:200px" placeholder="Tên của bạn" /></td>
                <td>Email:</td>
                <td><input name="" type="text" id="txtCEmail" style="width:250px" placeholder="Địa chỉ Email"/></td>
              </tr>
              <tr>
                <td colspan="4"><textarea name="" cols="10" rows="3" id="txtCContent" style="width:100%" placeholder="Hãy nhập ý kiến của bạn ở đây"></textarea></td>
                
              </tr>
              <tr>
                <td><!--Xác nhận:<input type="checkbox" id="chkCConfirm" /> --></td>
                <td><input name="" type="button" id="btnCSend" value="Gởi ý kiến" /></td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>
		<script type="text/javascript">
		$(document).ready(function(){
				var options1 = {
						'maxCharacterSize': 200,
						'originalStyle': 'originalTextareaInfo',
						'warningStyle' : 'warningTextareaInfo',
						'warningNumber': 20,
						'displayFormat' : '#input/#max ký tự'
				};
				$('#txtCContent').textareaCount(options1);
				$('#btnCSend').click(function(){
									$.ajax({
											url:"include/Comment_submit.php",
											data:{id:<?php echo $newsid; ?>,name:$('#txtCName').val(),email:$('#txtCEmail').val(),content:$('#txtCContent').val()},
											type:"post",
											dataType:"json",
											success:function(res)
												{
													if(res.ok)
													{
														$("#Comments").prepend(res.html);
													}
													else	
													{
														alert(res.msg);
													}
												}
											});
											  });
				//$('#chkCConfirm').lightSwitch();
				});
		</script>
            </div>
            <div id="Comments" style="max-height:300px; overflow-y:auto">
            	<?php
				$query="SELECT * FROM `comment` c WHERE c.NewsID=$newsid ORDER BY c.CommentID desc";
				$cres=mysql_query($query);
				while($crow=mysql_fetch_assoc($cres))
				{
				?>
                <div class="comment">
                <strong><?php echo $crow["AuthorName"]; ?></strong>&nbsp;(<?php $sqldate=strtotime($crow["CreatedDate"]); $date=date('d/m/Y',$sqldate); echo $date; ?> )
                <div><?php echo $crow["Content"]; ?></div></div>
                <?php
				}
				?>
            </div>
       </div>
        </p>
        <p >
        <label style="font-size:16px; color:#00F; font-weight:bold">Bài viết cùng chuyên mục:</label>
      <ul id="sametopic">
        <?php
		$query="SELECT n.NewsID, n.Title,n.CreatedDate FROM news n WHERE n.NewsID!=$newsid AND n.TopicID=".$news["TopicID"]." ORDER BY n.CreatedDate desc";
		$res1=mysql_query($query);
		while($snews=mysql_fetch_assoc($res1))
		{
		?>
   	    <li><a href="Detail.php?id=<?php echo $snews["NewsID"]; ?>"><?php echo $snews["Title"]; ?> </a>(<?php $sqldate=strtotime($snews["CreatedDate"]); $date=date('d/m/Y',$sqldate); echo $date; ?>)</li>
         <?php
		}
		 ?>
            
      </ul>
        </p>
     
      <p >
        <label style="font-size:16px; color:#00F; font-weight:bold">Bài viết cũ hơn:</label>
        <ul id="oldnews">
    		 <?php
		$query="SELECT n.NewsID, n.Title,n.CreatedDate FROM news n WHERE n.NewsID!=13 AND n.TopicID=".$news["TopicID"]." AND n.CreatedDate <= '$date' ORDER BY n.CreatedDate desc";
		$res2=mysql_query($query);
		while($onews=mysql_fetch_assoc($res2))
		{
		?>
            <li><a href="Detail.php?id=<?php echo $onews["NewsID"]; ?>"><?php echo $onews["Title"]; ?> </a>(<?php $sqldate=strtotime($onews["CreatedDate"]); $date=date('d/m/Y',$sqldate); echo $date; ?>)</li>
        
          <?php
		}
		 ?>
         </ul>
        </p>
    </div>
  	
  </div>
  
  <div class="right">
  <!----------------------------------------------Weather+Stock----------------------------------------------------->
  	<div id="weather">
    <?php include("../weather/index.php"); ?>
    </div>
   <div id="stock">
    <?php include("include/stock.html"); ?>
    </div> 
   <!----------------------------------------Hot News----------------------------------------->
     <div id="hotnews">
     	<div class="title"></div>
        <div class="hot">
       	  <ul>
            	 <?php
		  $hotsql="SELECT n.NewsID, n.Title, n.Image FROM news n WHERE n.IsDeleted=0 AND n.IsReview=1 ORDER BY n.Views DESC LIMIT 0,5 ";
		  $reshot=mysql_query($hotsql);
		  while($hot=mysql_fetch_assoc($reshot))
		  {
		  ?>
            	<li> 
                	<img src="<?php echo $urlNews.$hot["Image"]; ?>" alt="" style="width:80px; height:50px" />
                    <a href="Detail.php?id=<?php echo $hot["NewsID"]; ?>"><?php echo $hot["Title"]; ?></a>
                </li>
          <?php
		  }
		  ?>
            </ul>
       </div>
    </div>
    <!-----------------------------------Vote---------------------------------------------->
    <div id="vote">
    	<div class="title"></div>
        <div class="hot">
       	  	<form method="get" action="captcha/confirm.php" target="_blank">
        <?php
			$votesql="SELECT v.VoteID, v.VoteName, v.Content FROM vote v WHERE v.IsDeleted=0 AND v.IsEnd=0 AND v.TopicID=".$news["TopicID"]." ORDER BY v.CreatedDate desc LIMIT 0,1"; 
			$resvote=mysql_query($votesql);
			$vote=mysql_fetch_assoc($resvote);
			echo $vote["Content"];
			
		?>
            <ul>
            <?php
			$vdsql="SELECT v.VoteDetailID, v.Content FROM votedetail v WHERE v.VoteID=".intval($vote["VoteID"])." ORDER BY v.VoteDetailID";
			$resvd=mysql_query($vdsql);
			$k=0;
			while($dt=mysql_fetch_assoc($resvd))
			{
			?>
            	<li><label><input type="radio" name="answer" <?php if($k==0) echo "checked='checked'"; ?> value="<?php echo $dt["VoteDetailID"]; ?>"  /><?php echo $dt["Content"]; ?></label></li>
            <?php
			$k++;
			}
			?>
                <!--<li><label><input type="radio" name="answer" id="cauB" value="" />Đức</label></li>
                <li><label><input type="radio" name="answer" id="cauC" value="" />Pháp</label></li>
                <li><label><input type="radio" name="answer" id="cauD" value="" />Đội bóng khác</label></li> -->
            </ul>
            <?php
			if(mysql_num_rows($resvote)>0)
			{
			?>
            <a id="bieuquyet" target="_blank" href="include/StatisticResult.php?voteid=<?php echo $vote["VoteID"];  ?>">Thống kê</a>&nbsp;&nbsp;<input type="submit" value="Biểu quyết" />
            <?php
			}
			?>
          </form>
       </div>
    </div>
    
    <!-------------------------------------Advertisement-------------------------------------------->
    <div id="advertisement_right">
    	<div class="title"></div>
        <div class="hot">
       	  	
            <ul>
            	<?php 
			$query="SELECT a.AdvertiseName, a.FileType, a.FilePath, a.Link FROM advertisement a WHERE a.`Position`=4 AND a.IsDeleted=0 ORDER BY a.CreatedDate desc limit 0,5";
			
			$adver=mysql_query($query);
			while($row=mysql_fetch_assoc($adver))
			{
			
			switch($row['FileType'])
			{
				case 0:
				?>
				 <li><a href="<?php echo $row['Link']; ?>"><img alt="" src="<?php echo $urlAds.$row['FilePath']; ?>"   /></a></li>
				<?php
				break;
				case 1:
				?>
					<object width="250"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
			<param value="quangcao/qc1.swf" name="movie">
			<param value="high" name="quality">
			<embed width="250"  type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" quality="high" src="<?php echo $urlAds.$row['FilePath']; ?>">
			</object>
				<?php
				break;
			}
		
			}
			?>
          </ul>
           
       </div>
    </div>
  </div>
  
  
  
  <!------------------------------Footer--------------------------------------------------->
  <div class="footer">
  	<p>
    	Designed by: Nguyen Minh Nhat<br />
        Email: mimhnhat2110@gmail.com<br />
        Mobile: 0908311627
    </p>
  </div>
</div>
</body>
</html>